package com.kaifamiao.month04.day22;

import java.util.Arrays;

public class Hello {
    public static void main(String[] args) {
        int n = 100;
        // 定义数组变量标识某人是否还在圈内
        boolean[] isIn = new boolean[n];
        Arrays.fill(isIn, true);
        // 定义圈内人数、报数、索引
        int inCount = n;
        int countNum = 0;
        int index = 0;
        while (inCount > 1) {
            if (isIn[index]) {
                countNum++;
                if (countNum == 3) {
                    countNum = 0;
                    isIn[index] = false;
                    inCount--;
                }
            }
            index++;
            if (index == n)
                index = 0;
        }
        for (int i = 0; i < n; i++)
            if (isIn[i])
                System.out.println("留下的是：" + (i + 1));
    }
}
